<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="../js/jquery-3.4.1.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="../js/bootstrap.min.js"></script>
<!--    <script src="js/submit.js"></script>-->
    <title>Ymall</title>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-4 column">
        </div>
        <div class="col-md-4 column login">
            <form id="form1">
                <div class="form-group">
                    <img src="img/pic.png" alt="" style="width: 100%; border-radius: 5%">
                </div>
                <div class="form-group">
                    <label for="exampleInputPhone">用户名</label><input name="username" type="text" class="form-control" id="exampleInputPhone" placeholder="请输入您的用户名"/>
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">密码</label><input name="password" type="password" class="form-control" id="exampleInputPassword1" placeholder="请输入您的密码"/>
                </div>
                <div class="form-group" style="margin-left: 80%">
                    <label>忘记密码？</label>
                </div>
                <button type="button" id="submit" class="btn btn-default" style="margin-left: 40%">登录</button>
<!--                <div class="form-group">-->
                    <label style="margin-left: 8%;"><a href="Register.html">还没账号？请先注册</a></label>
<!--                </div>-->
            </form>
        </div>
        <div class="col-md-4 column">
        </div>
    </div>
</div>
<script>
    $("#submit").click(function () {
        $.ajax({
            type: "POST",      //提交的方法
            url:"http://localhost:8080/ycumall/UserServlet?method=login", //提交的地址
            data:$("#form1").serialize(), //序列化表单值输出
            async: false,
            error: function(request) {  //失败的话
                alert("提交失败 error");
            },
            success: function(data) {  //成功
                if(data.msg === 200) {
                    window.location.href="Ymall.html";
                } else {
                    alert(data.msg);
                }
            }
        });
    });
</script>
</body>
</html>